package com.hq.learnmybatisplus.dao;

import com.baomidou.mybatisplus.annotation.SqlParser;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.hq.learnmybatisplus.entity.PubRegionEntity;
import com.hq.learnmybatisplus.entity.User;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @author hq
 */
public interface TreeDao extends MyBaseMapper<PubRegionEntity> {

    /**
     * @param wrapper
     * SqlParser 3.1.1之前的版本需要在配置文件中 配置 mybatis-plus:global-config:sql-parser-cache: true
     * @return
     */
    //@SqlParser(filter = true)
    @Select("SELECT\n" +
            "\tb.name as yourName,\n" +
            "\tb.nm as yourNm,\n" +
            "  c.area,\n" +
            "\ta.*\n" +
            "FROM\n" +
            "\tpub_region a\n" +
            "\tLEFT JOIN t_info_owner b ON a.city_code = b.region\n" +
            "\tLEFT JOIN (select owner_nm,sum(area) as area from t_info_land  GROUP BY owner_nm ) c ON  b.nm = c.owner_nm \n" +
            "ORDER BY a.level_type ")
    List<PubRegionEntity> mySelectList();





}
